<?php declare(strict_types=1);

namespace App\Util;

use Illuminate\Support\Facades\Redis;

class LockUtil
{

    public static function expire(string $key, string $type = "PAY",int $second=2)
    {
        Redis::connection("default")->expire($type . $key, $second);
    }

    public static function lock(string $key, string $type = "PAY"): int
    {

        $lock = Redis::connection("default")->setnx($type . $key, 10);

        return $lock;
    }

    public static function unLock(string $key, string $type = "PAY"): void
    {

        Redis::connection("default")->del([$type . $key]);

    }

}